package recycle.controller;

import recycle.pojo.Hotrecycle;
import recycle.service.HotrecycleService;
import recycle.utils.Page;
import recycle.vo.HotrecycleParam;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 描述：热门回收表 控制器
* @author 孙冉
* @date 2019/07/22
*/
@RestController
@RequestMapping("/hotre" +
        "cycle")
public class HotrecycleController{
	@Resource
	private HotrecycleService hotrecycleService;
 	
 	@RequestMapping("/findById.json")
    public Hotrecycle findById(Integer hotRecycleId){
        Hotrecycle result = null;
        try {
            result = hotrecycleService.findById(hotRecycleId);
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 描述：获取所有的Hotrecycle对象
     */
    @RequestMapping("/findAll.json")
    public List<Hotrecycle> findAll(){
        List<Hotrecycle> result = null;
        try {
            result = hotrecycleService.findAll();
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 描述：新增保存Hotrecycle对象
     */
    @RequestMapping("/save.json")
    public Map save(Hotrecycle hotrecycle){
        Map result = new HashMap();
        result.put("flag",false);
        result.put("msg","保存热门回收表失败");
        try {
            if(hotrecycleService.save(hotrecycle)>0){
                result.put("flag",true);
                result.put("msg","保存热门回收表成功");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 描述：根据主键删除热门回收表对象
     * @param hotRecycleId
     */
    @RequestMapping("/delete.json")
    public Map delete(Integer hotRecycleId){
        Map result = new HashMap();
        result.put("flag",false);
        result.put("msg","保存热门回收表失败");
        try {
            if(hotrecycleService.delete(hotRecycleId)>0){
                result.put("flag",true);
                result.put("msg","保存热门回收表成功");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 描述：更新热门回收表对象
     */
    @RequestMapping("/update.json")
    public Map update(Hotrecycle hotrecycle){
        Map result = new HashMap();
        result.put("flag",false);
        result.put("msg","更新热门回收表失败");
        try {
            if( hotrecycleService.update(hotrecycle)>0){
                result.put("flag",true);
                result.put("msg","更新热门回收表成功");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;

    }

    /**
     * 根据不确定的条件，动态查询
     */
    @RequestMapping("/query.json")
    public List<Hotrecycle> query(HotrecycleParam param){
        List<Hotrecycle> result = null;
        try {
            result = hotrecycleService.query(param);
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 根据不确定的条件，动态分页查询
     */
    @RequestMapping("/queryByPage.json")
    public Page queryByPage(HotrecycleParam param){
        Page result = null;
        try {
            result = hotrecycleService.queryByPage(param);
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    @RequestMapping("/selectHotRecycleByCategory.json")
    public List<Hotrecycle> selectHotRecycleByCategory(){
        return hotrecycleService.selectHotRecycleByCategory();
    }

 }
